package com.guinea.account.service;

import java.io.Serializable;

import com.guinea.account.dao.ContactDao;
import com.guinea.account.entity.Contact;
import com.guinea.account.entity.User;
import com.guinea.core.orm.hibernate.HibernateDao;
import com.guinea.core.service.CRUDManager;

/**
 * @author huaxiaz
 */
public class ContactManager extends CRUDManager{
	private ContactDao contactDao;

	public HibernateDao getEntityDao() {
		return getContactDao();
	}

	public Contact getContact(Serializable id) {
		return (Contact)getContactDao().get(id);
	}

	public ContactDao getContactDao() {
		return contactDao;
	}

	public void setContactDao(ContactDao contactDao) {
		this.contactDao = contactDao;
	}

	
	public User getReferenceUser(Serializable id){
		return ((Contact)getEntityDao().get(id)).getUser();
	}

	public Contact getContactByUserId(Serializable id) {
		return (Contact)getContactDao().findUnique("select c from Contact c left join c.user u where u.id = ?",id);
	}
	
}
